using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {

        static Gamepeople gone;
        static Oberpeople gtwo;
        static Boolean TorF=false;
        static int c = 0;
        static string Gamename;

        static void Main(string[] args)
        {
            Game();
        }
        static void ChooseOber() {
            if (c == 1)
            {
                Gamename = "刘备";
            }
            else if (c == 2)
            {
                Gamename = "孙权";
            }
            else if (c == 3)
            {
                Gamename = "曹操";
            }        
            Console.WriteLine("请输入您的姓名:");
            string GameName = Console.ReadLine();
            gone = new Gamepeople(GameName);
            gtwo = new Oberpeople(Gamename);
            Console.WriteLine(gone.Name + " VS " + gtwo.Name + "   对战");

            Console.WriteLine("开始游戏吗？<y/n>");
            string numo = Console.ReadLine();
            if (numo == "y")
            {
                Start();
            }
            else
            {
                Console.WriteLine("已退出！！！");
            }
        }
        static void Game(){
            Console.WriteLine("---------------------欢迎进入游戏世界-----------------------\n\n\n");
            Console.WriteLine("**************************\n********猜拳，开始********\n**************************");
            Console.WriteLine("出拳规则：1.剪刀 2.石头 3.布");
            Console.WriteLine("请选择对方角色<1：刘备 2：孙权 3：曹操>");
            int num = Convert.ToInt32(Console.ReadLine());           
            
            switch (num)
            {
                case 1:
                    c = 1;
                    ChooseOber();
                    break;
                case 2:
                    c = 2;
                    ChooseOber();
                    break;
                case 3:
                    c = 3;
                    ChooseOber();
                    break;
                default:
                    Console.WriteLine("输入名字错误，请重新进入游戏！！");
                    Game();
                    break;
            }
        }
        static void EndScore() {
            Console.WriteLine("=============================================================");
            Console.WriteLine("姓名    " + "     得分");
            Console.WriteLine(gone.Name + "\t \t"+Gamepeople.gamescore);
            Console.WriteLine(gtwo.Name + "\t \t" + Oberpeople.oberscore);
            if (Gamepeople.gamescore > Oberpeople.oberscore)
            {
                Console.WriteLine("结果：" + gone.Name + "赢," + gtwo.Name + "笨蛋");
            }
            else if (Gamepeople.gamescore == Oberpeople.oberscore)
            {
                Console.WriteLine("平局，都不太行！！！");
            }
            else
            {
                Console.WriteLine("结果：" + gtwo.Name + "赢," + gone.Name + "笨蛋");
            }
        }
        static void AgainStart() {
           
            if (TorF == true)
            {
                Console.WriteLine("要开始下一局吗？（y/n）");
                string numo = Console.ReadLine();                         
                if (numo == "y")
                {
                    Game();
                }
                else
                {
                    Console.WriteLine("系统退出！");
                }
            }
            else {
                Console.WriteLine("是否要开始下一轮？<y/n>");
                string numo = Console.ReadLine();
              
                if (numo == "y")
                {                 
                    Start();
                }
                else
                {
                    EndScore();
                    Console.WriteLine("退出！");

                }
            }
        }
        static void Start() {                  
            Console.WriteLine("请出拳：1.剪刀 2.石头 3.布（输入相应数字：）");
            int num2 = Convert.ToInt32(Console.ReadLine());
            switch (num2)
            {
                case 1:
                    gone.fisttype = "剪刀";
                    Say();
                    break;
                case 2:
                    gone.fisttype = "石头";
                    Say();
                    break;
                case 3:
                    gone.fisttype = "布";
                    Say();
                    break;
                default:
                    break;
            }
            Win();
            AgainStart();

        }
        static void Win() {
            if (gone.fisttype == "剪刀" && Oberpeople.fistname == "剪刀")
            {
                Console.WriteLine("和局，真衰！嘿嘿，等着瞧吧！");
            }
            else if (gone.fisttype == "剪刀" && Oberpeople.fistname == "石头")
            {
                Console.WriteLine("笨蛋，" + gone.Name + "输了");
                Oberpeople.oberscore++;
            }
            else if (gone.fisttype == "剪刀" && Oberpeople.fistname == "布")
            {
                Console.WriteLine("恭喜，" + gone.Name + "赢了");
                Gamepeople.gamescore++;
            }
            else if (gone.fisttype == "石头" && Oberpeople.fistname == "石头")
            {
                Console.WriteLine("和局，真衰！嘿嘿，等着瞧吧！");
            }
            else if (gone.fisttype == "石头" && Oberpeople.fistname == "布")
            {
                Console.WriteLine("笨蛋，" + gone.Name + "输了");
                Oberpeople.oberscore++;
            }
            else if (gone.fisttype == "石头" && Oberpeople.fistname == "剪刀")
            {
                Console.WriteLine("恭喜，" + gone.Name + "赢了");
                Gamepeople.gamescore++;
            }
            else if (gone.fisttype == "布" && Oberpeople.fistname == "布")
            {
                Console.WriteLine("和局，真衰！嘿嘿，等着瞧吧！");
            }
            else if (gone.fisttype == "布" && Oberpeople.fistname == "剪刀")
            {
                Console.WriteLine("笨蛋，" + gone.Name + "输了");
                Oberpeople.oberscore++;
            }
            else if (gone.fisttype == "布" && Oberpeople.fistname == "石头")
            {
                Console.WriteLine("恭喜，" + gone.Name + "赢了");
                Gamepeople.gamescore++;
            }
            else
            {
                Console.WriteLine("我是谁？我在哪？");
            }
            AgainStart();
        }
        static void Say() {        
            gone.Play();
            gtwo.Play();
        }
    }
}